package com.kuaiyin.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.kuaiyin.sampling.BaseEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.io.Serializable;
import java.util.Map;

/**
 * <p>
 * JMeter测试用例关联表（存储用例与JMeter测试的映射关系）
 * </p>
 *
 * @author ng
 * @since 2025-07-03
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@TableName(value = "jmeter_case_relation", autoResultMap = true)
@Schema(name = "JmeterCaseRelation", description = "JMeter测试用例关联表")
public class JmeterCaseRelation extends BaseEntity implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(description = "关联ID（自增主键）")
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    @Schema(description = "关联的测试计划ID", example = "1001")
    private Long planId;

    @Schema(description = "关联的测试用例ID", example = "2001")
    private Long caseId;

    @Schema(description = "关联的JMeter测试ID", example = "3001")
    private Long jmeterId;

    @Schema(description = "JMeter响应提取配置（JSON格式）",
            example = "{\"token\":\"$.data.token\",\"userId\":\"$.data.user.id\"}")
    @TableField(typeHandler = JacksonTypeHandler.class)
    private Map<Object, Object> jmxResponseExtract;
}